<template>
  <div class="special-characters">
    <div class="container">
      <div id="content">
        <h1>特殊字符</h1>
        <div id="whatisit">
          <h2>什么是特殊字符（特殊符号）？</h2>
          <p>特殊字符（特殊符号）是相对于传统或常用的符号外，使用频率较少字符且难以直接输入的符号。比如数学符号，单位符号，制表符等。这些特殊字符是纯文本并且可以复制并粘贴到文本输入框中的，比如：微信对话框，微博、小红书的编辑框等。</p>
        </div>
        <div v-for="(category, index) in categories" :key="index" class="category-section">
          <h2>{{ category.name }}</h2>
          <p v-if="category.description">{{ category.description }}</p>
          <div class="list">
            <span v-for="char in category.chars" :key="char" @click="addCharacter(char)">{{ char }}</span>
          </div>
        </div>
      </div>
      <div id="copyS">
        <p>点击左侧字符，即可添加到文本框！</p>
        <el-input
          type="textarea"
          :rows="8"
          placeholder="选择的字符将显示在这里"
          v-model="selectedChars"
        ></el-input>
        <div class="button-group">
          <el-button type="primary" @click="copySelectedChars">
            <el-icon><DocumentCopy /></el-icon>
            复制选中字符
          </el-button>
          <el-button @click="clearSelectedChars">
            <el-icon><Delete /></el-icon>
            清空
          </el-button>
          <el-button type="warning" @click="goToHomepage">
            <el-icon><Back /></el-icon>
            返回首页
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { DocumentCopy, Delete, Back } from '@element-plus/icons-vue'
import { copyText } from '@/utils/clipboard'

const router = useRouter()
const selectedChars = ref('')

const categories = [
  {
    name: '热门特殊符号',
    chars: 'ღ•⁂€™↑→↓⇝√∞░▲▶◀●☀☁☂☃☄★☆☉☐☑☎☚☛☜☝☞☟☠☢☣☪☮☯☸☹☺☻☼☽☾♔♕♖♗♘♚♛♜♝♞♟♡♨♩♪♫♬✈✉✍✎✓✔✘✚✝✞✟✠✡✦✧✩✪✮✯✹✿❀❁❂❄❅❆❝❞❣❤❥❦❧➤ツ㋡卍웃ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ'
  },
  {
    name: '爱心特殊符号',
    description: '心形和爱情的文字符号。',
    chars: 'დღ♡❣❤❥❦❧♥'
  },
  {
    name: '手符号',
    chars: '☚☛☜☝☞☟✌✍'
  },
  {
    name: '国际象棋符号',
    chars: '♔♕♖♗♘♙♚♛♜♝♞♟'
  },
  {
    name: '音符符号',
    chars: '♩♪♫♬♭♮♯'
  },
  {
    name: '天气符号',
    description: '太阳，月亮，雨，云，流星，伞，温泉，堆雪人，冰晶符号。',
    chars: 'ϟ☀☁☂☃☄☉☼☽☾♁♨❄❅❆'
  },
  {
    name: '箭头特殊符号',
    description: '上下左右的箭头、风向、指南针符号',
    chars: '↕↖↗↘↙↚↛↜↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↶↷↸↹↺↻↼↽↾↿⇀⇁⇂⇃⇄⇅⇆⇇⇈⇉⇊⇋⇌⇍⇎⇏⇕⇖⇗⇘⇙⇚⇛⇜⇝⇞⇟⇠⇡⇢⇣⇤⇥⇦⇧⇨⇩⇪'
  },
  {
    name: '基本数学符号',
    chars: '+-×÷=≠≈≡±∓∞√∛∜∑∏∂∫∮∴∵∶∷∽∝∠∡∢∣∥∦∧∨∩∪∫∬∭∮∯∰∱∲∳'
  },
  {
    name: '集合符号',
    chars: '∅∈∉∋∌∏∐∑−∓∔∕∖∗∘∙√∛∜∝∞∟∠∡∢∣∤∥∦∧∨∩∪∫∬∭∮∯∰∱∲∳∴∵∶∷∸∹∺∻∼∽∾∿'
  },
  {
    name: '货币符号',
    description: '欧元，美元，美分，英镑，韩元，人民币和日元。',
    chars: '₮৲৳௹฿៛₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿﷼﹩＄￠￡￥￦'
  }
]

const addCharacter = (char) => {
  selectedChars.value += char
}

const copySelectedChars = () => {
  if (selectedChars.value) {
    copyText(selectedChars.value)
  }
}

const clearSelectedChars = () => {
  selectedChars.value = ''
}

const goToHomepage = () => {
  router.push('/')
}
</script>

<style lang="scss" scoped>
.special-characters {
  font-family: 'Roboto', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
  min-height: 100vh;
  padding: 40px 0;

  .container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
  }

  #content {
    flex: 2;
    padding: 30px;
    text-align: left;
  }

  #copyS {
    flex: 1;
    padding: 30px;
    background-color: #f8fafc;
    border-left: 1px solid #e0e6ed;

    .sticky-container {
      position: sticky;
      top: 20px; // 距离顶部的距离，可以根据需要调整
    }

    p {
      margin-bottom: 20px;
      font-size: 16px;
      color: #5a6d7e;
      text-align: center;
    }

    .el-input {
      margin-bottom: 20px;

      :deep(.el-textarea__inner) {
        min-height: 200px;
        font-size: 28px;
        line-height: 1.6;
        padding: 15px;
        letter-spacing: 0.1em;
        border-radius: 8px;
        border: 2px solid #d1d9e6;
        transition: all 0.3s ease;

        &:focus {
          border-color: #4a90e2;
          box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
        }
      }
    }

    .button-group {
      display: flex;
      justify-content: space-between;
      margin-top: 20px;

      .el-button {
        flex: 1;
        margin: 0 5px;
        height: 44px;
        font-size: 16px;
        border-radius: 8px;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;

        .el-icon {
          margin-right: 5px;
        }

        &:hover {
          transform: translateY(-2px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        &.el-button--primary {
          background-color: #4a90e2;
          border-color: #4a90e2;
        }

        &.el-button--warning {
          background-color: #f5a623;
          border-color: #f5a623;
        }
      }
    }
  }

  h1, h2 {
    color: #2c3e50;
    margin-bottom: 20px;
  }

  h1 {
    font-size: 36px;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 10px;
  }

  h2 {
    font-size: 24px;
    margin-top: 40px;
    color: #3498db;
  }

  p {
    margin-bottom: 20px;
    font-size: 16px;
    color: #34495e;
  }

  .category-section {
    margin-bottom: 40px;
  }

  .list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;

    span {
      display: inline-flex;
      justify-content: center;
      align-items: center;
      width: 60px;
      height: 60px;
      background-color: #fff;
      border: 1px solid #e0e6ed;
      border-radius: 8px;
      cursor: pointer;
      font-size: 28px;
      transition: all 0.3s ease;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);

      &:hover {
        background-color: #3498db;
        color: #fff;
        transform: translateY(-3px);
        box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
      }
    }
  }

  .button-group {
    display: flex;
    justify-content: space-between;

    .el-button {
      flex: 1;
      margin: 0 5px;
    }
  }
}

@media (max-width: 768px) {
  .special-characters {
    padding: 20px 0;

    .container {
      flex-direction: column;
    }

    #content {
      padding: 20px;
    }

    #copyS {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background-color: #fff;
      padding: 20px;
      box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
      z-index: 1000;
      border-left: none;
      border-top: 1px solid #e0e6ed;

      .sticky-container {
        position: static;
      }

      p {
        font-size: 14px;
      }

      .el-input {
        :deep(.el-textarea__inner) {
          min-height: 120px;
          font-size: 24px;
        }
      }

      .button-group {
        margin-top: 15px;

        .el-button {
          height: 40px;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
